const express = require("express");
const multer = require('multer')();

const restrict = require(__util + "/restrict")  // 路由拦截中间件

const router = module.exports = express.Router({
  mergeParams: true // 保留父路由器中的req.params
});

// ------------------------文件资源管理--------------------------
router.use("/file", restrict.intercept())
router.route("/file/upload")
  .post(multer.any(), require("./file/upload")) // 上传文件

// ------------------------后台管理账号管理--------------------------
router.use("/account", restrict.intercept())
router.route("/account/updatePassword")
  .post(require("./account/updatePassword")) // 修改用户密码

// ---------------------------支付管理--------------------------
// 针对当前使用"/payment"路由的添加路由拦截验证
router.use("/payment", restrict.intercept())
router.route("/payment/list")
  .post(require("./payment/list")) // 获取支付列表

router.route("/payment/create")
  .post(require("./payment/create")) // 新增支付类型

router.route("/payment/update")
  .post(require("./payment/update")) // 修改支付类型

// -------------------------eos账号管理-------------------------
router.use("/eosaccount", restrict.intercept())
router.route("/eosaccount/list")
  .post(require("./eosaccount/list")) // 获取支付列表

router.route("/eosaccount/recreate")
  .post(require("./eosaccount/recreate")) // 重新创建账号


// -------------------------eos节点管理-------------------------
router.use("/eosendpoint", restrict.intercept())
router.route("/eosendpoint/list")
  .post(require("./eosendpoint/list")) // 获取节点列表

router.route("/eosendpoint/create")
  .post(require("./eosendpoint/create")) // 新增节点

router.route("/eosendpoint/update")
  .post(require("./eosendpoint/update")) // 更新节点状态

// -------------------------日志管理-------------------------
router.use("/servicelog", restrict.intercept())
router.route("/servicelog/list")
  .post(require("./servicelog/list")) // 获取日志列表

// -------------------------第三方app管理-------------------------
router.use("/thirdpartyapp", restrict.intercept())
router.route("/thirdpartyapp/distinct")
  .post(require("./thirdpartyapp/distinct")) // 获取分类

router.route("/thirdpartyapp/fetch")
  .post(require("./thirdpartyapp/fetch")) // 获取第三方app列表

router.route("/thirdpartyapp/create")
  .post(require("./thirdpartyapp/create")) // 新建第三方app

router.route("/thirdpartyapp/update")
  .post(require("./thirdpartyapp/update")) // 更新第三方app

router.route("/thirdpartyapp/delete")
  .post(require("./thirdpartyapp/delete")) // 删除第三方app
